<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>出差申请</title>
    <script src="../../../../../res/js/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="../../../../../res/js/login_common.js" charset="utf-8"></script>
    <script src="../../../../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../../../../res/js/Tools.js" charset="utf-8"></script>
    <link rel="shortcut icon" type="image/x-icon" href="../../../../../res/images/favicon.ico">
    <link rel="stylesheet" href="../../../../../res/layui/css/layui.css" media="all">
</head>
<body style="padding: 10px">
<div style="display: none" id="bodys">
    <form action="" class="layui-form layui-form-pane" lay-filter="example">
        <h1 align="center" style="margin-bottom: 20px">出差申请表</h1>
        <input class="layui-hide" lay-verify="required" type="text" id="applyPersonnelId"
               name="applyPersonnelId"/>
        <input class="layui-hide" lay-verify="required" type="text" id="personnelId"
               name="personnelId"/>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">申请人</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" id="applyPersonnelName"
                    />
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">出差人</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" id="personnelName"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">申请时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="travelBusinessTime" name="travelBusinessTime">
                </div>
            </div>


            <div class="layui-inline">
                <label class="layui-form-label">差旅类型</label>
                <div class="layui-input-inline">
                   <select id="travelBusinessType" name="travelBusinessType"></select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">交通工具</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="travelBusinessVehicles"/>
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">差旅出发地</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="travelBusinessDepart"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">差旅目的地</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="required" type="text" name="travelBusinessPurpose"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="travelBusinessStartTime" name="travelBusinessStartTime">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="travelBusinessEndTime" name="travelBusinessEndTime">
                </div>
            </div>


        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">出差原因</label>
            <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea"
                      name="travelBusinessReason" lay-verify="required">       </textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" id="batchOvertimeDetailCause"
                      name="remark" lay-verify="required">       </textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">添加附件</label>
            <div style="width: 100%;height: 50px;border:#ddd 1px solid;border-top:none;padding-top: 5px;padding-left: 20px;box-sizing: border-box;">
                <button class="layui-btn test" lay-data="{url: '/b/', accept: 'file'}">上传文件</button>
            </div>
        </div>
        <!-- 提交-->
        <div class="layui-form-item" id="sub" style="margin: 30px 0;">
            <div class="layui-input-block" id="flows">
                <button type="submit" class="layui-btn site-demo-active" lay-submit="" lay-filter="demo1">立即提交</button>
                <input type="button" class="layui-btn layui-btn-warm" style="display: none" id="deleteById"
                       value="取消申请"/>
            </div>
        </div>
    </form>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
        <legend>流程日志</legend>
    </fieldset>
    <ul class="layui-timeline" id="schedule">

    </ul>
</div>
<script>
    let pkTravelBusinessId = getQueryString("pkTravelBusinessId");
    layui.use(['form', 'laydate', 'table', 'upload'], function () {
        var table = layui.table;
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate;
        laydate.render({
            elem: '#travelBusinessTime' //指定元素
        });
        laydate.render({
            elem: '#travelBusinessStartTime' //指定元素
        });
        laydate.render({
            elem: '#travelBusinessEndTime' //指定元素
        });
        if (pkTravelBusinessId) {
            res = getAjaxById(getRootPath() + "OaTravelBusinessFlowAction/findOaTravelBusinessFlowIdById/" + pkTravelBusinessId);
            console.log(res);
            //流程id
            $("#pkTravelBusinessId").val(res.pkTravelBusinessId);
            //流程进度
            $("#isRevision").val(res.isRevision);
            //申请人
            $("#personnelId").val(res.personnelId);

            let date = new Date(res.batchOvertimeDetailStart);

            let dateEnd = new Date(res.batchOvertimeDetailEnd);

        } else {
            res = getAjaxById(getRootPath() + "OaPersonnelAction/getUser");
            console.log(res)
            // 员工名称
            $("#applyPersonnelId").val(res.pkPersonnelId);
            $("#applyPersonnelName").val(res.personnelName);
            $("#personnelId").val(res.pkPersonnelId);
            $("#personnelName").val(res.personnelName);


        }
        $("#bodys").show();
        loadBusinessType();
        form.render();

    });

    /*出差类型*/
    function loadBusinessType() {
        const nation = getAjaxById(getRootPath() + "OaDataDictionaryAction/findKeyword/BUSINESSWAY");
        $.each(nation, function (index, item) {
            $("#travelBusinessType").append("<option value='" + item.pkDataDictionaryId + "'>" + item.dataDictionaryName + "</option>");
        });
    }
</script>
</body>
</html>